/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ages.test.swat

import com.ages.entity.Actor
import com.ages.graphics.GLDraw
import com.ages.graphics.Sprite
import com.ages.graphics.ViewportSwitcher
import com.ages.math.Vector
import com.ages.math.Vector3D
import javax.media.opengl.GL

object Smack{
  val sprite = new Sprite("/com/ages/test/res/smack_small.png",1,1,1)
}

class Smack(v:Vector,dmg:Double) extends Actor {
  depth = DepthPlaces.FX
  
  pos = Vector3D(v.X,v.Y,1)
  var time = 0

  def getDmg = dmg
  def think(){
    time += 1
    if(time>0)
      markForDeletion = true
  }

  def draw(gl:GL)
  {
    val spot = Vector3D(pos.X,pos.Y,1)
    val box = () =>{
      gl.glEnable(GL.GL_BLEND);
//     Select blending function
      gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
      gl.glColor4d(1,1,1,1/time)
      gl.glTranslated(-100,-100,0)
      Smack.sprite.drawWithoutDisplaylist(gl, 0 , 0)
    }
    gl.glDisable(GL.GL_LIGHTING)
    ViewportSwitcher.setup2DView(gl)

    
//    GLDraw draw box at spot on gl

//    gl.glPushMatrix
//    gl.glTranslated(pos.X,pos.Y,pos.Z)
//    gl.glColor4d(1,1,1,1)
//    gl.glBegin(GL.GL_QUADS)
//    gl.glVertex2d(-20,-20)
//    gl.glVertex2d(20,-20)
//    gl.glVertex2d(20,20)
//    gl.glVertex2d(-20,20)
//    gl.glEnd
//
//    gl.glPopMatrix
  }

}
